/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CajeroRefrendo.java
 *
 * Created on 09-nov-2009, 21:05:28
 */

package scapi.gui;

import java.awt.Component;
import java.awt.event.KeyEvent;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import scapi.entidades.BoletaEmpenio;
import scapi.entidades.Pignorante;
import scapi.entidades.Producto;
import scapi.servidor.servidores.ServidorAEmpenio;
import scapi.utilerias.EValidacion;
import scapi.utilerias.ExcepcionValidacion;
import scapi.utilerias.ServidorFactory;

/**
 *
 * @author Admin
 */
public class CajeroRefrendo extends javax.swing.JPanel {
    private ServidorAEmpenio servEmpenio;
    private BoletaEmpenio bol;
    private Pignorante pig;
    private Producto pro;

    /** Creates new form CajeroRefrendo */
    public CajeroRefrendo() {
        initComponents();
        try {
            servEmpenio = (ServidorAEmpenio) ServidorFactory.obtenerServidor(ServidorFactory.ServidorEmpenio);
        } catch (RemoteException ex) {
            Logger.getLogger(CajeroPagos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NotBoundException ex) {
            Logger.getLogger(CajeroPagos.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(CajeroPagos.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        txtClaveBoleta = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        txtRecargoRefrendo = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jDateChooser2 = new com.toedter.calendar.JDateChooser();
        pnInformacion = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        txtNombreBoleta = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtApBoleta = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtRfcBoleta = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jDtFechaBoleta = new com.toedter.calendar.JDateChooser();
        jLabel7 = new javax.swing.JLabel();
        txtProductoBoleta = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtDescBoleta = new javax.swing.JTextArea();
        jLabel9 = new javax.swing.JLabel();
        txtAvaluoBoleta = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtPrestamoBoleta = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtInteres = new javax.swing.JTextField();

        jLabel1.setText("Clave de Boleta");

        txtClaveBoleta.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtClaveBoletaKeyTyped(evt);
            }
        });

        jButton2.setText("Buscar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jLabel13.setText("Recargo por refrendo:");

        txtRecargoRefrendo.setFocusable(false);

        jButton4.setText("Refrendar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jButton5.setText("Borrar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel14.setText("Fecha:");

        jDateChooser2.setEnabled(false);

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(8, 8, 8)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtClaveBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, 278, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel14)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDateChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, 224, Short.MAX_VALUE)
                        .addGap(138, 138, 138))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(731, 731, 731))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtRecargoRefrendo, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(584, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel14)
                        .addComponent(jButton2)
                        .addComponent(txtClaveBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1))
                    .addComponent(jDateChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 386, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(txtRecargoRefrendo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jButton4))
                .addGap(29, 29, 29))
        );

        pnInformacion.setBorder(javax.swing.BorderFactory.createTitledBorder("Información de la Boleta"));

        jLabel3.setText("Nombre:");

        txtNombreBoleta.setEnabled(false);
        txtNombreBoleta.setFocusable(false);

        jLabel4.setText("Apellido:");

        txtApBoleta.setEnabled(false);
        txtApBoleta.setFocusable(false);
        txtApBoleta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtApBoletaActionPerformed(evt);
            }
        });

        jLabel5.setText("RFC:");

        txtRfcBoleta.setEnabled(false);
        txtRfcBoleta.setFocusable(false);

        jLabel6.setText("Fecha:");

        jDtFechaBoleta.setBackground(new java.awt.Color(255, 255, 255));
        jDtFechaBoleta.setEnabled(false);
        jDtFechaBoleta.setFocusable(false);

        jLabel7.setText("Producto:");

        txtProductoBoleta.setEnabled(false);
        txtProductoBoleta.setFocusable(false);
        txtProductoBoleta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtProductoBoletaActionPerformed(evt);
            }
        });

        jLabel8.setText("Descripción:");

        txtDescBoleta.setColumns(20);
        txtDescBoleta.setRows(5);
        txtDescBoleta.setEnabled(false);
        jScrollPane1.setViewportView(txtDescBoleta);

        jLabel9.setText("Avaluo:");

        txtAvaluoBoleta.setEnabled(false);
        txtAvaluoBoleta.setFocusable(false);

        jLabel10.setText("Prestamo:");

        txtPrestamoBoleta.setEnabled(false);
        txtPrestamoBoleta.setFocusable(false);
        txtPrestamoBoleta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPrestamoBoletaActionPerformed(evt);
            }
        });

        jLabel11.setText("Interes:");

        txtInteres.setEnabled(false);
        txtInteres.setFocusable(false);
        txtInteres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtInteresActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnInformacionLayout = new javax.swing.GroupLayout(pnInformacion);
        pnInformacion.setLayout(pnInformacionLayout);
        pnInformacionLayout.setHorizontalGroup(
            pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnInformacionLayout.createSequentialGroup()
                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnInformacionLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel5)
                                    .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel9)
                                        .addComponent(jLabel6)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtAvaluoBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
                                    .addComponent(jDtFechaBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
                                    .addComponent(txtPrestamoBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)
                                    .addComponent(txtRfcBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 283, Short.MAX_VALUE)))
                            .addGroup(pnInformacionLayout.createSequentialGroup()
                                .addContainerGap()
                                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(pnInformacionLayout.createSequentialGroup()
                                        .addComponent(jLabel3)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txtNombreBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
                                    .addGroup(pnInformacionLayout.createSequentialGroup()
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(txtApBoleta, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)))))
                        .addGap(26, 26, 26))
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel10)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(18, 18, 18)
                        .addComponent(txtProductoBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel8)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(18, 18, 18)
                        .addComponent(txtInteres, javax.swing.GroupLayout.PREFERRED_SIZE, 215, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(157, 157, 157))
        );
        pnInformacionLayout.setVerticalGroup(
            pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnInformacionLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(txtNombreBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(txtApBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(txtRfcBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jDtFechaBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(txtAvaluoBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(txtPrestamoBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(pnInformacionLayout.createSequentialGroup()
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(txtProductoBoleta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel8)
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addGroup(pnInformacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel11)
                            .addComponent(txtInteres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(47, 47, 47))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnInformacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(89, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(79, 79, 79)
                .addComponent(pnInformacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(147, Short.MAX_VALUE))
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(35, 35, 35)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    try{
        int numero = EValidacion.numeroCorrecto(this.txtClaveBoleta.getText(), "Clave de Boleta");
        bol = servEmpenio.obtenerBoleta(numero);

            Date fechaFin = servEmpenio.obtenerFechaLimite(numero);
            Date hoy = new Date();

            if(hoy.compareTo(fechaFin)<0)
                throw new ExcepcionValidacion("Aun no es tiempo de refrendar");




        pig = bol.getPignorante();
        pro = bol.getProducto();
        float cantRestante = servEmpenio.cantPago(numero);
        float pago = servEmpenio.intereseGen(numero);
        float recargos = 0;




        float total = cantRestante + recargos;


        txtNombreBoleta.setText(pig.getNombre());
        txtApBoleta.setText(pig.getApPaterno());
        txtAvaluoBoleta.setText(""+bol.getAvaluo());
        txtDescBoleta.setText(pro.getDescripcion());
        txtPrestamoBoleta.setText(""+bol.getPrestamo());
        txtProductoBoleta.setText(pro.getNombre());
        jDtFechaBoleta.setDate(bol.getFecha());
        txtRfcBoleta.setText(pig.getRfc());
        txtInteres.setText(""+bol.getIntereses());



        txtRecargoRefrendo.setText(""+pago);



        }
        catch(ExcepcionValidacion e){
            JOptionPane.showMessageDialog(this,e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
        }catch(Exception e){
            e.printStackTrace();

        }
}//GEN-LAST:event_jButton2ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            float monto = EValidacion.flotante(txtRecargoRefrendo.getText(), "Monto");
            servEmpenio.refrendarBoleta(1, bol.getId(), pig.getId(), monto);
            
            JOptionPane.showMessageDialog(this, "Refrendo apliacado correctamente");
            limpiarForm();


            // TODO add your handling code here:
        } catch (ExcepcionValidacion ex) {
            Logger.getLogger(CajeroRefrendo.class.getName()).log(Level.SEVERE, null, ex);
        }catch(Exception e){
            e.printStackTrace();
        }

        // TODO add your handling code here:
}//GEN-LAST:event_jButton4ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

        limpiarForm();
        // TODO add your handling code here:
}//GEN-LAST:event_jButton5ActionPerformed

    private void txtClaveBoletaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtClaveBoletaKeyTyped
            char caracter = evt.getKeyChar();
         if( ((caracter < '0') || (caracter > '9')) &&(caracter != KeyEvent.VK_BACK_SPACE) ){
                evt.consume();}        // TODO add your handling code here:
    }//GEN-LAST:event_txtClaveBoletaKeyTyped

    private void txtApBoletaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtApBoletaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtApBoletaActionPerformed

    private void txtProductoBoletaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtProductoBoletaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtProductoBoletaActionPerformed

    private void txtPrestamoBoletaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPrestamoBoletaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtPrestamoBoletaActionPerformed

    private void txtInteresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtInteresActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtInteresActionPerformed

private void limpiarPanel(JPanel panel){
        Component[] comp = panel.getComponents();
        for (int i = 0; i < comp.length; i++) {
            Component component = comp[i];
            if(component instanceof JTextField){
                JTextField componente = (JTextField) component;
                componente.setText("");
            }else if(component instanceof JComboBox){
                JComboBox comp2 = (JComboBox) component;
                comp2.setSelectedIndex(0);

            }else if(component instanceof JCheckBox){
                JCheckBox box = (JCheckBox) component;
                box.setSelected(false);
            }

        }

    }

    private void limpiarForm(){
        limpiarPanel(pnInformacion);
        txtDescBoleta.setText("");
        txtRecargoRefrendo.setText("");
        
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private com.toedter.calendar.JDateChooser jDateChooser2;
    private com.toedter.calendar.JDateChooser jDtFechaBoleta;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel pnInformacion;
    private javax.swing.JTextField txtApBoleta;
    private javax.swing.JTextField txtAvaluoBoleta;
    private javax.swing.JTextField txtClaveBoleta;
    private javax.swing.JTextArea txtDescBoleta;
    private javax.swing.JTextField txtInteres;
    private javax.swing.JTextField txtNombreBoleta;
    private javax.swing.JTextField txtPrestamoBoleta;
    private javax.swing.JTextField txtProductoBoleta;
    private javax.swing.JTextField txtRecargoRefrendo;
    private javax.swing.JTextField txtRfcBoleta;
    // End of variables declaration//GEN-END:variables

}
